﻿

namespace AceSoft.RetailPlus
{
    using System;
    using System.Data.Entity;
    using System.Data.EntityModel;
    using System.Linq;
    using AceSoft.RetailPlus.ContactModel;

    public class ContactNoMock
    {
        public ContactNoMock()
        {
            Contact _Contact = new Contact();

            DbSet<ContactNo> _ContactNoes = _Contact.ContactNoes;

            Console.WriteLine("Available contactno");
            foreach (ContactNo _ContactNo in _ContactNoes)
            {
                Console.WriteLine(" {0} : {1}", _ContactNo.ContactNoType, _ContactNo.PhoneNo);
            }

            Console.WriteLine("Deleting contactno");
            foreach (ContactNo _ContactNo in _ContactNoes)
            {
                _ContactNoes.Remove(_ContactNo);
                Console.WriteLine(" ContactDetail {0} : {1} deleted.", _ContactNo.ContactNoType, _ContactNo.PhoneNo);
            }
            _Contact.SaveChanges();

            Console.WriteLine("Adding contactno");
            foreach (ContactDetail _ContactDetail in _Contact.ContactDetails)
            {
                _ContactNoes.Add(new ContactNo { ContactID = _ContactDetail.ID, ContactNoType = "Office Phone", PhoneNo = "oxx" + _ContactDetail.ID });
                _ContactNoes.Add(new ContactNo { ContactID = _ContactDetail.ID, ContactNoType = "Home Phone", PhoneNo = "hxx" + _ContactDetail.ID });
                _ContactNoes.Add(new ContactNo { ContactID = _ContactDetail.ID, ContactNoType = "Mobile No", PhoneNo = "mxx" + _ContactDetail.ID });
                Console.WriteLine(" ContactDetail Office Phone: {0} added.", "oxx" + _ContactDetail.ID);
                Console.WriteLine(" ContactDetail Home Phone: {0} added.", "hxx" + _ContactDetail.ID);
                Console.WriteLine(" ContactDetail Mobile No: {0} added.", "mxx" + _ContactDetail.ID);
            }
            _Contact.SaveChanges();

            Console.WriteLine("Relisting contactno");
            foreach (ContactNo _ContactNo in _ContactNoes)
            {
                Console.WriteLine(" {0} : {1}", _ContactNo.ContactNoType, _ContactNo.PhoneNo);
                Console.WriteLine(" Contact: {0} ", _ContactNo.ContactDetail.FirstName);
            }
        }
    }
}
